package com.lengxf.kafka.kafkaTest;

import com.lengxf.kafka.admin.AdminService;
import com.lengxf.kafka.producer.Producer;
import lombok.AllArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping
@AllArgsConstructor
public class TestController {

    private final Producer producer;

    private final AdminService adminService;

    @Scheduled(cron = "0/5 * * * * ?")
    @GetMapping("send")
    public String testSend() {
        producer.sendMsg("发送了一条神奇的消息...");
        return "success";
    }

    @GetMapping("topicInfo")
    public Integer topicInfo() {
        return adminService.topicPartitionCount("foo3");
    }

    @GetMapping("partitionIncreaseTo")
    public String partitionIncreaseTo(int count) {
        adminService.partitionIncreaseTo("foo3", count);
        return "success";
    }

}
